package com.grf.hadoop.practice;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class HttpDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(HttpDriver.class);
        job.setMapperClass(HttpMapper.class);
        job.setReducerClass(HttpReducer.class);
        job.setMapOutputKeyClass(HttpBean.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(HttpBean.class);
        job.setOutputValueClass(NullWritable.class);
        job.setNumReduceTasks(5);
        job.setPartitionerClass(HttpPartitioner.class);
        FileInputFormat.setInputPaths(job, new Path("C:\\Users\\Administrator\\Desktop\\大数据\\data\\http_log.txt"));
        FileOutputFormat.setOutputPath(job, new Path("C:\\Users\\Administrator\\Desktop\\output"));
        job.waitForCompletion(true);
    }
}
